<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/common/common.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title>添加工作日志</title>
    <link rel="stylesheet" href="./css/layui.css">
</head>
<body>

<form id="form" name="form" class="layui-form" action="<%= basePath%>/WorkAction_add.action" method="post">
    <div class="layui-form-item">
        <label class="layui-form-label">工作编号</label>
        <div class="layui-input-block">
            <input type="number" name="workId" id="workId" required="required"  placeholder="请输入工作编号" autocomplete="off" class="layui-input"/>
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">周次</label>
        <div class="layui-input-block">
            <input type="text" name="weekly" id="weekly" required="required" placeholder="请输入周次" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">工作时间</label>
        <div class="layui-input-block">
            <input type="date" name="workTime" id="workTime" required="required"  />
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">星期 </label>
        <div class="layui-input-block">
            <input type="text" name="week" id="week" required="required" placeholder="请输入星期" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">人员姓名</label>
        <div class="layui-input-block">
            <input type="text" name="username" id="username" required="required" placeholder="请输入人员姓名" autocomplete="off" class="layui-input" />
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">工作内容</label>
        <div class="layui-input-block">
            <input type="text" name="workContent" id="workContent" required="required" placeholder="请输入工作内容" autocomplete="off" class="layui-input" />
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            <a onclick="javascript:history.back(-1);" class="layui-btn layui-btn-warm"><i class="layui-icon">&#xe65c;</i>返回</a>
        </div>
    </div>
</form>
<script src="./js/jquery.js" type="text/javascript"></script>
<script src="./js/layui.all.js" type="text/javascript"></script>
<script src="./js/layui.js" type="text/javascript"></script>

<script type="text/javascript">
    //Demo
    layui.use(['form'], function(){
        var form = layui.form;
        //监听提交
        form.on('submit(formDemo)', function(data){

        });
        form.render();
    });
</script>

<script type="text/javascript">
layui.use([ 'form' ], function() {
	var form = layui.form, layer = layui.layer;
	form.on('submit(formDemo)', function(data) {
		//判断不能为空，不会其他了，太拙劣了，重复且量大
		/* if (document.form.planId.value==""||document.form.planId.value==null){
		window.alert("请填写招聘计划编号.")
		return false;
		}else if (document.form.planName.value==""||document.form.planName.value==null){
		window.alert("请填写招聘计划名称.")
		return false;
		}else if (document.form.requirement.value==""||document.form.requirement.value==null){
		window.alert("请填写岗位要求.")
		return false;
		}else if (document.form.num.value==""||document.form.num.value==null||document.form.num.value>99){
		window.alert("请填写 <=99 的招聘人数.")
		return false;
		}else if (document.form.department.value==""||document.form.department.value==null){
		window.alert("请填写申请部门.")
		return false;
		}else if (document.form.username.value==""||document.form.username.value==null){
		window.alert("请填写申请人.")
		return false;
		} */
	
		var workId=$("#workId").val();
		var weekly=$("#weekly").val();
		var workTime=$("#workTime").val();
		var week=$("#week").val();
		var username=$("#username").val();
		var workContent=$("#workContent").val();
		$.ajax({
			type:'POST',
			url:'<%= basePath%>/WorkAction_add.action',
			data:{workId:workId,weekly:weekly,workTime:workTime,week:week,username:username,workContent:workContent},
			//判断从后台传值过来的data数据
			success:function(data){
				alert("添加成功！");
				//点击确定按钮后执行list动作
				window.location.href="<%= basePath%>/WorkAction_list.action"
			}
		});
		return false;
	});
 
});

</script>

</body>
</html>